<?php if(!defined('BASEPATH'))exit('No direct script access allowed'); ?>
<?php $this->load->view('admin/global/header'); ?>
<?php $this->load->view('admin/global/left'); ?>
<table cellpadding="0" cellspacing="0">
    <tr>
        <td class="title"><?php if(isset($user)){echo lang('EDIT').': '.lang('MEMBER');}else{echo lang('ADD').': '.lang('MEMBER');} ?></td>
    </tr>
    <?php if(isset($denied)){ ?>
    <tr>
        <td class="bar">
            <div class="error"><?php echo lang('DENIED'); ?></div>
            <meta http-equiv="refresh" content="5; <?php echo base_url().ADMIN_PATH; ?>" />
        </td>
    </tr>
    <?php }else{ ?>
    <?php if($success == true){ ?>
    <tr>
        <td class="bar">
            <div class="success"><?php echo lang('SUCCESS_UPDATED_DATA'); ?></div>
            <meta http-equiv="refresh" content="1" />
        </td>
    </tr>
    <?php }else{ ?>
    <?php echo Modules::run('admin/bar_module/index', $buttons); ?>
    <tr>
        <td valign="top">
        <form name="frmPost" id="frmPost" method="post" enctype="multipart/form-data">
            <table class="form" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('USERNAME'); ?>:</td>
                    <td>
                        <input type="text" name="txtUsername" class="input" value="<?php if(isset($user)){echo set_value('txtUsername', $user->useUsername);}else{echo set_value('txtUsername');} ?>" />
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('USERNAME_TIP'); ?>" align="top" />
                        <?php echo form_error('txtUsername'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('PASSWORD'); ?>:</td>
                    <td>
                        <input type="password" name="txtPassword" class="input" value="" />
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('PASSWORD_TIP'); ?>" align="top" />
                        <?php echo form_error('txtPassword'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('REINPUT_PASSWORD'); ?>:</td>
                    <td>
                        <input type="password" name="txtConfirmPassword" class="input" value="" />
                        <?php echo form_error('txtConfirmPassword'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('EMAIL'); ?>:</td>
                    <td>
                        <input type="text" name="txtEmail" class="input" value="<?php if(isset($user)){echo set_value('txtEmail', $user->useEmail);}else{echo set_value('txtEmail');} ?>" />
                        <?php echo form_error('txtEmail'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('REINPUT_EMAIL'); ?>:</td>
                    <td>
                        <input type="text" name="txtConfirmEmail" class="input" value="<?php if(isset($user)){echo set_value('txtConfirmEmail', $user->useEmail);}else{echo set_value('txtConfirmEmail');} ?>" />
                        <?php echo form_error('txtConfirmEmail'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('AVATAR'); ?>:</td>
                    <td>
                        <input type="file" name="txtAvatar" />
                        <?php if(isset($user)){ ?>
                        <img src="<?php echo base_url(); ?>templates/admin/images/expand.png" class="tip vtip" title="<?php echo tip(base_url().show_thumbnail('thumbnail250X205_', $user->useAvatar, IMAGE_PATH.'avatars/'.$user->useDirAvatar.'/', 'templates/home/images/defaultAvatar.jpg'), true); ?>" align="top" style="margin-top:4px;" />
                        <?php } ?>
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('AVATAR_TIP'); ?>" align="top" />
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('FULLNAME'); ?>:</td>
                    <td>
                        <input type="text" name="txtFullname" class="input" value="<?php if(isset($user)){echo set_value('txtFullname', $user->useFullname);}else{echo set_value('txtFullname');} ?>" />
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('BIRTHDAY'); ?>:</td>
                    <td>
                        <input type="text" name="txtBirthday" class="inputDate birthdayPicker" value="<?php if(isset($user) && (int)$user->useBirthday != 0){echo set_value('txtBirthday', date_convert($user->useBirthday, true, false));}else{echo set_value('txtBirthday');} ?>" />
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('BIRTHDAY_TIP'); ?>" align="top" />
                        <?php echo form_error('txtBirthday'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label0"><?php echo lang('SEX'); ?>:</td>
                    <td>
                        <input type="radio" name="txtSex" class="radio" value="1" <?php if(isset($user) && (int)$user->useSex == 1){echo set_radio('txtSex', 1, true);}else{echo set_radio('txtSex', 1, true);} ?> />
                        <span style="margin-right:20px;"><b><?php echo lang('MALE'); ?></b></span>
                        <input type="radio" name="txtSex" class="radio" value="2" <?php if(isset($user) && (int)$user->useSex == 0){echo set_radio('txtSex', 2, true);}else{echo set_radio('txtSex', 2);} ?> />
                        <span><b><?php echo lang('FEMALE'); ?></b></span>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('ADDRESS'); ?>:</td>
                    <td>
                        <input type="text" name="txtAddress" class="input" value="<?php if(isset($user)){echo set_value('txtAddress', $user->useAddress);}else{echo set_value('txtAddress');} ?>" />
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('PROVINCE'); ?>:</td>
                    <td>
                        <select name="txtProvince" class="select">
                            <?php foreach($provinces as $province){ ?>
                            <option value="<?php echo $province->preID; ?>" <?php if(isset($user) && (int)$user->useProvince == (int)$province->preID){echo set_select('txtProvince', $province->preID, true);}else{echo set_select('txtProvince', $province->preID);} ?>><?php echo $province->preName; ?></option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('PHONE'); ?>:</td>
                    <td>
                        <input type="text" name="txtPhone" class="input" value="<?php if(isset($user)){echo set_value('txtPhone', $user->usePhone);}else{echo set_value('txtPhone');} ?>" />
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('TEL_FAX_TIP'); ?>" align="top" />
                        <?php echo form_error('txtPhone'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('MOBILE'); ?>:</td>
                    <td>
                        <input type="text" name="txtMobile" class="input" value="<?php if(isset($user)){echo set_value('txtMobile', $user->useMobile);}else{echo set_value('txtMobile');} ?>" />
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('TEL_FAX_TIP'); ?>" align="top" />
                        <?php echo form_error('txtMobile'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('FAX'); ?>:</td>
                    <td>
                        <input type="text" name="txtFax" class="input" value="<?php if(isset($user)){echo set_value('txtFax', $user->useFax);}else{echo set_value('txtFax');} ?>" />
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('TEL_FAX_TIP'); ?>" align="top" />
                        <?php echo form_error('txtFax'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('YAHOO'); ?>:</td>
                    <td>
                        <input type="text" name="txtYahoo" class="input" value="<?php if(isset($user)){echo set_value('txtYahoo', $user->useYahoo);}else{echo set_value('txtYahoo');} ?>" />
                        <?php echo form_error('txtYahoo'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('SKYPE'); ?>:</td>
                    <td>
                        <input type="text" name="txtSkype" class="input" value="<?php if(isset($user)){echo set_value('txtSkype', $user->useSkype);}else{echo set_value('txtSkype');} ?>" />
                        <?php echo form_error('txtSkype'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('GROUP'); ?>:</td>
                    <td>
                        <select name="txtGroup" id="txtGroup" class="select" <?php if(isset($user) && (int)$user->useID == (int)$this->session->userdata('idAdmin')){echo 'disabled="disabled"';} ?>>
                            <?php foreach($groups as $group){ ?>
                            <?php if(((int)$group->groID != 4 && (int)$this->session->userdata('groupAdmin') > 4) || (int)$this->session->userdata('groupAdmin') == 4){ ?>
                            <option value="<?php echo $group->groID; ?>" <?php if(isset($user) && (int)$user->useGroup == (int)$group->groID){echo set_select('txtGroup', $group->groID, true);}else{echo set_select('txtGroup', $group->groID);} ?>><?php echo $group->groName; ?></option>
                            <?php } ?>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr id="expireDate" style="display:none;">
                    <td class="label"><span class="red">*</span> <?php echo lang('EXPIRE_DATE'); ?>:</td>
                    <td>
                        <input type="text" name="txtExpireDate" class="inputDate expirePicker" value="<?php if(isset($user) && (int)$user->useExpireDate > 0){echo set_value('txtExpireDate', date_convert($user->useExpireDate, true, false));}else{echo set_value('txtExpireDate');} ?>" />
                        <span style="margin-left:5px; margin-right:5px;"><b><?php echo lang('OR'); ?></b></span>
                        <select name="txtNumberDate" class="select">
                            <?php for($i = 0; $i <= (EXPIRE_TIME*30); $i++){ ?>
                            <option value="<?php echo $i; ?>" <?php echo set_select('txtNumberDate', $i); ?>><?php echo $i; ?></option>
                            <?php } ?>
                        </select>
                        <span style="margin-left:5px;"><b><?php echo lang('DATE'); ?></b></span>
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('EXPIRE_DATE_TIP'); ?>" align="top" />
                        <?php echo form_error('txtExpireDate'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label0"><?php echo lang('ACTIVE'); ?>:</td>
                    <td>
                        <input type="checkbox" name="txtStatus" class="checkbox" value="1" <?php if(isset($user) && (int)$user->useStatus == 1){echo set_checkbox('txtStatus', 1, true);}else{echo set_checkbox('txtStatus', 1);} ?> <?php if(isset($user) && (int)$user->useID == (int)$this->session->userdata('idAdmin')){echo 'disabled="disabled"';} ?> />
                    </td>
                </tr>
            </table>
        </form>
        </td>
    </tr>
    <?php } ?>
    <?php } ?>
</table>
<?php $this->load->view('admin/global/right'); ?>
<?php $this->load->view('admin/global/footer'); ?>